/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.mobbuzz.renderer;

import com.sun.lwuit.CheckBox;
import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Font;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.list.ListCellRenderer;
import edu.mobbuzz.bean.Category;
/**
 *
 * @author dailicious
 */
public class CategoryCheckBoxRenderer extends Container implements ListCellRenderer{

    private CheckBox checkBox = new CheckBox("");
    private Label focus = new Label("");
  

    public CategoryCheckBoxRenderer(){
        setLayout(new BorderLayout());
        Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS));

        checkBox.getStyle().setFont(Font.createSystemFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_SMALL));
        checkBox.getStyle().setBgTransparency(0);
        checkBox.getStyle().setMargin(0, 0, 0, 0);

       
        cnt.addComponent(checkBox);

        addComponent(BorderLayout.CENTER, cnt);
        focus.getStyle().setBgTransparency(100);
        focus.getStyle().setBgColor(0xCCCCCC);
    }

    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
        
        Category category = (Category) value;
        checkBox.setText(category.getLabel());
        checkBox.setSelected(category.isSelected());

        return this;
    }

    public Component getListFocusComponent(List list) {
        
        return focus;
    }
    

}
